package com.example.leetdemo.finash;

public class Solution2241 {



    static class ATM {

        int[] paperArr = new int[5];
        int[] amountArr = new int[] {20, 50, 100, 200, 500};

        public ATM() {
        }

        public void deposit(int[] banknotesCount) {
            for (int i = 0; i < banknotesCount.length; i++) {
                paperArr[i] += banknotesCount[i];
            }
        }

        public int[] withdraw(int amount) {
            int balance = amount;

            int[] draw = new int[5];
            for (int i = 4; i >= 0; i--) {
                draw[i] = Math.min(balance / amountArr[i], paperArr[i]);
                balance = balance - draw[i] * amountArr[i];
            }
            if (balance > 0) {
                return new int[] {-1};
            }
            for (int i = 0; i < draw.length; i++) {
                paperArr[i] -= draw[i];
            }
            return draw;
        }
    }

    public static void main(String[] args) {
        ATM atm = new ATM();
        atm.deposit(new int[]{0,0,1,2,1});
        int[] a = atm.withdraw(600);
        System.err.println(0);
        StringBuilder builder = new StringBuilder();

        System.err.println(Integer.toBinaryString(Integer.parseInt("10")));
    }

}
